<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>数据库同步</title>
  <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
  <link rel="stylesheet" href="/systemStatic/style/admin.css">
  <link rel="stylesheet" href="/iconfont/iconfont.css"/>
  <link rel="stylesheet" href="/css/public.css">
  <script type="text/javascript">
    var __ctx = "";
  </script>
</head>
<body>
<div class="layui-container" style="margin-top: 50px">
  <div class="layui-row">
    <h2 style="text-align: center">ORACLE数据同步</h2>
    <a class="layui-btn" onclick="syncData()" style="float: right">
      <span>全部同步</span>
    </a>
  </div>
</div>
<form class="layui-form">
  <div class="layui-container" style="margin-top: 50px">
    <div class="layui-row">
      <table class="layui-table">
        <thead>
        <tr>
          <th width="50">序号</th>
          <th width="400">表名称</th>
          <th width="100">管理</th>
        </tr>
        </thead>
        <tbody>
        <#list tableList as tableName>

        <tr>
          <td>${tableName_index+1}</td>
          <td>${tableName}</td>
          <td>
            <a class="layui-btn" onclick="syncDataByName('${tableName}')">同步整表数据</a>
          </td>
        </tr>
        </tbody>
      </#list>
      </table>
    </div>
  </div>
</form>
<script src="/public/component.js" type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<script>
  function syncDataByName(tableName) {
    layui.use(['jquery', 'layer'], function () {
      var $ = layui.jquery;
      var layer = layui.layer;

      var index = layer.load(1, {shade: [0.1, '#cccccc']});
      $.ajax({
        url: serverPath.basePath + '/dataSynchronization/doSyncDataByName',
        data: {tableName: tableName},
        dataType: 'json',
        type: 'post',
        success: function (data) {
          layer.close(index);
          layer.msg(data.msg);
        }
      });
    })
  }

  function syncData() {
    layui.use(['jquery', 'layer'], function () {
      var $ = layui.jquery;
      var layer = layui.layer;
      var index = layer.load(3, {
        shade: [0.2, '#cccccc'],
      });
      $.ajax({
        url: serverPath.basePath + '/dataSynchronization/doSyncData',
        dataType: 'json',
        type: 'get',
        success: function (data) {
          layer.close(index);
          layer.msg(data.msg);
        }
      });
    })
  }


</script>
</body>
</html>